<template>
  <el-dialog
    draggable
    overflow
    v-model="visible"
    :title="'需求'"
    :width="1324"
    destroy-on-close
    @closed="$emit('closed')"
  >
    <el-form :model="form" ref="dialogForm1">
      <el-row>
        <el-col :span="24">
          <el-form-item label="标题" prop="title">
            <el-input v-model="form.title"> </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="18">
          <sc-editor
            v-model="form.html"
            placeholder="请输入"
            :height="600"
            :uuid="form.uuid"
          ></sc-editor>
        </el-col>
        <el-col :span="6">
          <sc-editor v-model="form.remark" placeholder="请输入" :height="600"></sc-editor
        ></el-col>
      </el-row>
    </el-form>
    <template #footer>
      <el-button type="primary" :loading="isSaveing" @click="submit()">保 存</el-button>
    </template>
  </el-dialog>
</template>

<script>
import { defineAsyncComponent } from "vue";
const scEditor = defineAsyncComponent(() => import("@/components/skEditor"));

export default {
  name: "issue",
  components: {
    scEditor,
  },
  data() {
    return {
      form: { html: "", title: "", uuid: [], status_id: 0 },
      isSaveing: false,
      visible: false,
    };
  },
  methods: {
    open(mode = "add") {
      this.mode = mode;

      this.visible = true;

      return this;
    },
    setData(data) {
      this.form = data;
    },
    submit() {
      this.$refs.dialogForm1.validate(async (valid) => {
        if (valid) this.isSaveing = true;
        var res = await this.$API.issue.save.post(this.form);
        this.isSaveing = false;
        if (res.code == 200) {
          this.$emit("success", this.form, this.mode);
          this.visible = false;
          this.$message.success("操作成功");
        }
      });
    },
  },
};
</script>

<style></style>
